package cn.com.acca.ma.dao.impl;

import cn.com.acca.ma.dao.UserColumnCommentDao;
import cn.com.acca.ma.hibernate.util.HibernateUtil;
import cn.com.acca.ma.model.db.UserColumnComment;
import org.hibernate.Query;

import java.util.ArrayList;
import java.util.List;

public class UserColumnCommentDaoImpl extends BaseDaoImpl<UserColumnCommentDaoImpl> implements UserColumnCommentDao {

    public UserColumnCommentDaoImpl() {
        super();
    }

    /**
     * 查询comments列不为空的所有记录
     * @return
     */
    @Override
    public List<UserColumnComment> findByCommentNotNull() {
        logger.info("查询所有记录");

        List<UserColumnComment> list = new ArrayList<UserColumnComment>();
        session = HibernateUtil.currentSession();
        session.beginTransaction();
        Query query = session.createQuery("SELECT t FROM UserColumnComment t where t.comments is not null");
        list = query.list();
        session.getTransaction().commit();
        session.close();
        return list;
    }
}
